
#include "gamecontrol.h"

GameControl* GameControl::instance = nullptr;

GameControl::GameControl()
{

}

GameControl *GameControl::Instance()
{
    if(instance == nullptr)
    {
        return instance = new GameControl();
    }
}
GameControl::~GameControl()
{
    if(instance != nullptr)
        delete instance;
    instance = nullptr;
}

void GameControl::setParent(Widget *Parent)
{
    this->parent = Parent;
}

void GameControl::GameInit()
{
    mGameView.setSceneRect(QRect(0,0,GameDefine::ScreenWidth,GameDefine::ScreenHeight));//游戏主界面大小
    LoadMS();//加载谱面文件
    CreateTimer();//创建计时器
    LoadStartScene();//初始化开始场景
    LoadMainScene();//初始化主场景
    LoadStopScene();//初始化暂停场景
    LoadEndScene();//初始化结算场景

    //添加场景到视图
    mGameView.setScene(&mStartScene);//先显示开始场景
    mGameView.setParent(parent);//设置视图的父类
    mGameView.show();
}

void GameControl::LoadMS()
{
    //打开谱面文件
    mMS = new MusicScore(parent);
    mMS->InitByFile(GameDefine::MSAddress);
}

void GameControl::LoadStartScene()
{
    //初始化主界面和开始场景
    mStartScene.setSceneRect(QRect(0,0,GameDefine::ScreenWidth,GameDefine::ScreenHeight));//场景大小
    mStartScene.setBackgroundBrush (QBrush(qRgb (0,0,0)));//场景颜色

    //未完成的gif添加
    //gif1.resize(256,103);
    //Gifplayer1.setVideoOutput(&gif1);//添加显示器
    //Gifplayer1.setSource(QUrl(":/gif/xinhaichigua.gif"));//设置播放视频
    //Gifplayer1.play();
    //videoWidget = new QVideoWidget(this);
    //videoWidget->resize(500, 300);
    //player->setVideoOutput(videoWidget);

    LoadStartPushbutton();//PushButton初始化
    LoadStartAddPicture();//添加元素图片
    LoadStartPos();//元素位置设定
    LoadStartAddItem();//元素添加到场景
    TimerConnect();//按钮、定时器功能连接
}

void GameControl::LoadStartPos()
{
    //初始化各个元素的位置
    mStartBackground.setPos(0,0);
    mTitle1.setPos(237,50);
    mTitle2.setPos(134,259);
    mTitle3->move(151,380);
    // player.setPosition(qint64());
}

void GameControl::LoadStartAddItem()
{
    //将各个元素添加到初始场景中
    mStartScene.addItem(&mStartBackground);
    mStartScene.addItem(&mTitle1);
    mStartScene.addItem(&mTitle2);
    mStartScene.addWidget(mTitle3);
    // mStartScene.addItem(&gif1);
}

void GameControl::LoadStartAddPicture()
{
    //给背景和轨道设置图片
    mTitle1.setPixmap(QPixmap(":/img/Title1.png"));
    mTitle2.setPixmap(QPixmap(":/img/Title2.png"));
    mTitle3->setIcon(QIcon(":/img/Title4.png"));
}

void GameControl::LoadStartPushbutton()
{
    //PushButton创建
    mTitle3 = new QPushButton;
    mTitle3->resize(498,75);
    mTitle3->setIconSize(QSize(498,75));

}

void GameControl::LoadMainScene()
{
    mMainScene.setSceneRect(QRect(0,0,GameDefine::ScreenWidth,GameDefine::ScreenHeight));//场景大小
    mMainScene.setBackgroundBrush (QBrush(qRgb (0,0,0)));//场景颜色
    LoadMainPushButton();//初始化按钮
    LoadMainSettingItems();//初始化主场景元素
    LoadMainAddPicture();//给主场景元素添加图片
    LoadMainPos();//设置主场景元素的位置
    LoadMainAddItem();//将各元素添加到主场景
}

void GameControl::LoadMainAddItem()
{
    mMainScene.addWidget(stop);//设置暂停按钮到场景
    mMainScene.addItem(&mBackground);//设置背景图到场景
    mMainScene.addItem(&mTrack1);//设置轨道到场景
    mMainScene.addItem(&mTrack2);
    mMainScene.addItem(&mTrack3);
    mMainScene.addItem(&mTrack4);
    mMainScene.addItem(mPoints);//设置分数标签到场景
    mMainScene.addItem(mLv);//设置难度标签到场景
    mMainScene.addItem(mPName);//设置谱面名称标签到场景
    mMainScene.addItem(mCombo);//设置Combo标签到场景
    mMainScene.addItem(mComboNum);//设置连击数标签到场景
    mMainScene.addItem(mStatus);//设置状态显示到场景


}

void GameControl::LoadMainAddPicture()
{
    //给背景和轨道设置图片
    mTrack1.setPixmap(QPixmap(":/img/TrackC75.png"));
    mTrack2.setPixmap(QPixmap(":/img/TrackC75.png"));
    mTrack3.setPixmap(QPixmap(":/img/TrackC75.png"));
    mTrack4.setPixmap(QPixmap(":/img/TrackC75.png"));

    mBackground.setPixmap(QPixmap(mMS->getBackGround()));
    LoadMainAddEffect();//给背景图片添加效果
    mBackground.setGraphicsEffect(mBGBlurEffect);
    mBackground.setGraphicsEffect(mBGOpacityEffect);

    stop->setIcon(QIcon(":/img/StopButton50.png"));
}

void GameControl::LoadMainAddEffect()
{
    mBGBlurEffect = new QGraphicsBlurEffect(parent);//模糊效果
    mBGBlurEffect->setBlurRadius(30);

    mBGOpacityEffect = new QGraphicsOpacityEffect(parent);//透明效果
    mBGOpacityEffect->setOpacity(0.7);
}

void GameControl::LoadMainSettingItems()
{
    //初始化分数
    mPoints = new QGraphicsTextItem;
    mPoints->setPlainText(QString("%1").arg(mMS->getPoints(), 7, 10, QLatin1Char('0')));
    mPoints->setDefaultTextColor(QColor(255,255,255));//颜色
    mPoints->setFont(QFont("Courier New",23,100));//字体

    //初始化难度
    mLv = new QGraphicsTextItem;
    mLv->setPlainText(QString("Lv.%1").arg(mMS->getLevel()));
    mLv->setDefaultTextColor(QColor(255,255,255));//颜色
    mLv->setFont(QFont("Courier New",20,60));//字体

    //初始化谱面名称
    mPName = new QGraphicsTextItem;
    mPName->setPlainText(mMS->getName());
    mPName->setDefaultTextColor(QColor(255,255,255));//颜色
    mPName->setFont(QFont("Courier New",14,80));//字体

    //初始化combo标签
    mCombo->setDefaultTextColor(QColor(255,255,255));//颜色
    mCombo->setFont(QFont("Dosis",50,80));//字体

    //初始化连击数
    mComboNum = new QGraphicsTextItem;
    mComboNum->setPlainText(QString("%1").arg(mMS->getComboNum()));//初状态连击数
    mComboNum->setDefaultTextColor(QColor(255,255,255));//颜色
    mComboNum->setFont(QFont("Dosis",45,80));//字体

    //状态显示
    mStatus = new QGraphicsTextItem;
    mStatus->setFont(QFont("Dosis",30,80));//字体
}

void GameControl::LoadMainPos()
{
    //初始化各个元素的位置
    mBackground.setPos(0,0);
    mTrack1.setPos(300,0);//各轨道位置
    mTrack2.setPos(380,0);
    mTrack3.setPos(460,0);
    mTrack4.setPos(540,0);
    mPoints->setPos(640,0);//分数位置
    mLv->setPos(700,565);//难度位置
    mPName->setPos(5,565);//谱面名称位置
    mCombo->setPos(60,150);
    qreal width1 = mCombo->boundingRect().width();//"Combo"宽度
    qreal width2 = mComboNum->boundingRect().width();//ComboNum宽度
    mComboNum->setPos(60+width1/2-width2/2,230);//初始化ComboNum位置(居中)
    stop->move(0,0);
}

void GameControl::LoadMainPushButton()
{
    stop = new QPushButton;
    stop->resize(50,50);
    stop->setIconSize(QSize(50,50));
}

void GameControl::LoadEndScene()
{
    mEndScene.setSceneRect(QRect(0,0,GameDefine::ScreenWidth,GameDefine::ScreenHeight));//场景大小
    mEndScene.setBackgroundBrush (QBrush(qRgb (0,0,0)));//场景颜色
    LoadEndBGM();//加载结算界面BGM
    LoadEndAddPicture();//添加结算界面元素图片
    LoadEndPos();//设置结算界面元素位置
    LoadEndAddItem();//将各元素添加到结算场景
}

void GameControl::LoadEndBGM()
{
    //初始化背景音乐
    EndBGMPlayer = new QMediaPlayer(this);
    EndBGMPlayer->setSource(QUrl("qrc:/audio/EndBGM.mp3"));
    EndBGMPlayer->setLoops(-1);//设置循环播放
    EndBGMOutput = new QAudioOutput(this);
    EndBGMOutput->setVolume(0.3);
    EndBGMPlayer->setAudioOutput(EndBGMOutput);
}

void GameControl::LoadEndAddItem()
{
    mEndScene.addItem(&mEndBackground);//设置背景图到场景
    mEndScene.addItem(&mEndRect);
    mEndScene.addItem(&mRank);
    mEndScene.addItem(mEndName);
    mEndScene.addItem(mScore);
    mEndScene.addItem(mMaxCombo);
    mEndScene.addItem(mMaxComboNum);
    mEndScene.addItem(mAccuracy);
    mEndScene.addItem(mAccuracyNum);
    mEndScene.addItem(mPerfect);
    mEndScene.addItem(mPerfectNum);
    mEndScene.addItem(mGood);
    mEndScene.addItem(mGoodNum);
    mEndScene.addItem(mBad);
    mEndScene.addItem(mBadNum);
    mEndScene.addItem(mMiss);
    mEndScene.addItem(mMissNum);
    //mEndScene.addWidget(EndReset);
}

void GameControl::LoadEndAddEffect()
{
    mEBGBlurEffect = new QGraphicsBlurEffect(this);//模糊效果
    mEBGBlurEffect->setBlurRadius(30);

    mEBGOpacityEffect = new QGraphicsOpacityEffect;//透明效果
    mEBGOpacityEffect->setOpacity(0.7);
}

void GameControl::LoadEndAddPicture()
{
    //初始化背景
    mEndBackground.setPixmap(QPixmap(mMS->getBackGround()));
    LoadEndAddEffect();
    mEndBackground.setGraphicsEffect(mEBGBlurEffect);
    mEndBackground.setGraphicsEffect(mEBGOpacityEffect);

    //初始化矩形
    mEndRect.setPixmap(QPixmap(":/img/EndBackGround.png"));

    //初始化谱名
    mEndName = new QGraphicsTextItem;
    mEndName->setPlainText(mMS->getName());
    mEndName->setDefaultTextColor(QColor(255,255,255));//颜色
    mEndName->setFont(QFont("Courier New",30,80));//字体

    //初始化分数
    mScore = new QGraphicsTextItem;
    mScore->setDefaultTextColor(QColor(255,255,255));//颜色
    mScore->setFont(QFont("Courier New",50,80));//字体

    //初始化最大连击数
    mMaxCombo->setDefaultTextColor(QColor(255,255,255));//颜色
    mMaxCombo->setFont(QFont("Dosis",15,80));//字体

    mMaxComboNum = new QGraphicsTextItem;
    mMaxComboNum->setDefaultTextColor(QColor(255,255,255));//颜色
    mMaxComboNum->setFont(QFont("Courier New",30,80));//字体

    //初始化准度
    mAccuracy->setDefaultTextColor(QColor(255,255,255));//颜色
    mAccuracy->setFont(QFont("Dosis",15,80));//字体

    mAccuracyNum = new QGraphicsTextItem;
    mAccuracyNum->setDefaultTextColor(QColor(255,255,255));//颜色
    mAccuracyNum->setFont(QFont("Courier New",30,80));//字体

    //初始化P
    mPerfect->setDefaultTextColor(QColor(255,255,255));//颜色
    mPerfect->setFont(QFont("Dosis",15,80));//字体

    mPerfectNum = new QGraphicsTextItem;
    mPerfectNum->setDefaultTextColor(QColor(255,255,255));//颜色
    mPerfectNum->setFont(QFont("Courier New",30,80));//字体

    //初始化G
    mGood->setDefaultTextColor(QColor(255,255,255));//颜色
    mGood->setFont(QFont("Dosis",15,80));//字体

    mGoodNum = new QGraphicsTextItem;
    mGoodNum->setDefaultTextColor(QColor(255,255,255));//颜色
    mGoodNum->setFont(QFont("Courier New",30,80));//字体

    //初始化B
    mBad->setDefaultTextColor(QColor(255,255,255));//颜色
    mBad->setFont(QFont("Dosis",15,80));//字体

    mBadNum = new QGraphicsTextItem;
    mBadNum->setDefaultTextColor(QColor(255,255,255));//颜色
    mBadNum->setFont(QFont("Courier New",30,80));//字体

    //初始化M
    mMiss->setDefaultTextColor(QColor(255,255,255));//颜色
    mMiss->setFont(QFont("Dosis",15,80));//字体

    mMissNum = new QGraphicsTextItem;
    mMissNum->setDefaultTextColor(QColor(255,255,255));//颜色
    mMissNum->setFont(QFont("Courier New",30,80));//字体

    //初始化Reset按钮
    //EndReset = new QPushButton(parent);
    //EndReset->setText("↻");
}

void GameControl::LoadEndPos()
{
    mEndRect.setPos(0,100);//矩形位置
    mRank.setPos(50,150);//Rank位置
    mEndName->setPos(5,100);//谱面名称位置
    mScore->setPos(400,170);//分数位置
    mMaxCombo->setPos(300,270);//最大连击数名称位置
    mMaxComboNum->setPos(360,300);//最大连击数位置
    mAccuracy->setPos(550,270);//准度名称位置
    mAccuracyNum->setPos(610,300);//准度位置
    mPerfect->setPos(5,400);//P名称位置
    mPerfectNum->setPos(50,425);//P位置
    mGood->setPos(200,400);//G名称位置
    mGoodNum->setPos(250,425);//G位置
    mBad->setPos(400,400);//B名称位置
    mBadNum->setPos(450,425);//B位置
    mMiss->setPos(600,400);//M名称位置
    mMissNum->setPos(650,425);//M位置
    //EndReset->move(0,0);//Reset按钮位置
}

void GameControl::CreateTimer()
{
    //创建计时器
    mMSTimer = new QTimer(parent);
    mDelay = new QTimer(parent);
    mDetectKeyTimer = new QTimer(parent);
    BGMDelay = new QTimer(parent);
    MSDelay = new QTimer(parent);
    MusicTimer = new QTimer(parent);
    stopDelay = new QTimer(parent);
}

void GameControl::TimerConnect()
{
    //按钮跳转事件和谱面计时器打开事件
    connect(mTitle3,&QToolButton::clicked,[this](){
        mGameView.setScene(&mMainScene);
        mGameView.show();
        mDelay->start(GameDefine::MSDelay);//设置缓冲
        BGMDelay->start(GameDefine::Delay);//设置缓冲
    });

    //缓冲时间到后
    connect(mDelay,&QTimer::timeout,[this](){
        mMSTimer->start(GameDefine::MSTime);//打开谱面计时器
        mDetectKeyTimer->start(GameDefine::Border);//打开判定检测器
        MSDelay->start(mMS->getMusicLenth()+GameDefine::EndDelay);
        mMS->setparent(&mMainScene);//添加谱面至场景
        mDelay->stop();
    });

    //BGM缓冲计时器
    connect(BGMDelay,&QTimer::timeout,[this](){
        mMS->BGMPlayer->play();
        MusicTimer->start(1);//开启播放时间计时器
        StopButtonConnect();
        BGMDelay->stop();
    });

    //谱面计时器
    connect(mMSTimer,&QTimer::timeout,[this](){
        mMS->notesMove(mMS->getSpeed());
    });

    //判定计时器
    connect(mDetectKeyTimer,&QTimer::timeout,this,&GameControl::judgeStatus);
    connect(mDetectKeyTimer,&QTimer::timeout,this,&GameControl::ShowStatus);//显示状态
    connect(mDetectKeyTimer,&QTimer::timeout,this,&GameControl::ShowComboNum);//显示连击数
    connect(mDetectKeyTimer,&QTimer::timeout,this,&GameControl::ShowPoints);//显示分数
    //边界判定
    connect(mDetectKeyTimer,&QTimer::timeout,[this](){
        mMS->JudgeBorder(&mMainScene);
    });

    //播放时间计时器
    connect(MusicTimer,&QTimer::timeout,[this](){
        mMS->updateMusicTime();
    });

    //最终界面跳转计时器
    connect(MSDelay,&QTimer::timeout,[this](){
        mGameView.setScene(&mEndScene);
        ResetEnddata();
        EndBGMPlayer->play();//播放结算音乐
        mGameView.show();
    });
}

void GameControl::judgeStatus()
{
    for(int keyCode : parent->mKeyList){
        switch(keyCode){
        case Qt::Key_S:
        {
            mMS->setStatus(mMS->JudgeStatus(1,&mMainScene));//按键S->1轨道
            parent->mKeyList.removeOne(Qt::Key_S);
            break;
        }
        case Qt::Key_D:
        {
            mMS->setStatus(mMS->JudgeStatus(2,&mMainScene));//按键D->2轨道
            parent->mKeyList.removeOne(Qt::Key_D);
            break;
        }
        case Qt::Key_J:
        {
            mMS->setStatus(mMS->JudgeStatus(3,&mMainScene));//按键J->3轨道
            parent->mKeyList.removeOne(Qt::Key_J);
            break;
        }
        case Qt::Key_K:
        {
            mMS->setStatus(mMS->JudgeStatus(4,&mMainScene)) ;//按键K->4轨道
            parent->mKeyList.removeOne(Qt::Key_K);
            break;
        }
        }
    }
}

void GameControl::ShowStatus()
{
    QString Status;
    switch(mMS->getStatus()){
    case 0:
    {
        Status = " ";
        mStatus->setPos(80,300);//状态显示位置
        break;
    }
    case 1:
    {
        Status = "Perfect";
        mStatus->setDefaultTextColor(QColor(255,222,3));//颜色
        mStatus->setPos(80,300);//状态显示位置
        break;
    }
    case 2:
    {
        Status = "Good";
        mStatus->setDefaultTextColor(QColor(160,255,255));//颜色
        mStatus->setPos(105,300);//状态显示位置
        break;
    }
    case 3:
    {
        Status = "Bad";
        mStatus->setDefaultTextColor(QColor(255,255,255));//颜色
        mStatus->setPos(117,300);//状态显示位置
        break;
    }
    case 4:
    {
        Status = "Miss";
        mStatus->setDefaultTextColor(QColor(255,255,255));//颜色
        mStatus->setPos(108,300);//状态显示位置
        break;
    }
    }
    mStatus->setPlainText(Status);
}

void GameControl::ShowComboNum()
{
    mComboNum->setPlainText(QString("%1").arg(mMS->getComboNum()));
}

void GameControl::ShowPoints()
{
    mMS->CalculatePoints();
    mPoints->setPlainText(QString("%1").arg(mMS->getPoints(), 7, 10, QLatin1Char('0')));
}

void GameControl::ResetEnddata()
{
    mMS->JudgeRank();
    mRank.setPixmap(QPixmap(mMS->getRank()));
    mScore->setPlainText(QString("%1").arg(mMS->getPoints(), 7, 10, QLatin1Char('0')));
    mMaxComboNum->setPlainText(QString("%1").arg(mMS->getMaxComboNum()));
    mAccuracyNum->setPlainText(QString("%1%").arg(mMS->getAcc()*100,0,'g',4));
    mPerfectNum->setPlainText(QString("%1").arg(mMS->getPerfectNum()));
    mGoodNum->setPlainText(QString("%1").arg(mMS->getGoodNum()));
    mBadNum->setPlainText(QString("%1").arg(mMS->getBadNum()));
    mMissNum->setPlainText(QString("%1").arg(mMS->getMissNum()));
}

void GameControl::LoadStopScene()
{
    mEndScene.setSceneRect(QRect(0,0,GameDefine::ScreenWidth,GameDefine::ScreenHeight));//场景大小
    mEndScene.setBackgroundBrush (QBrush(qRgb (0,0,0)));//场景颜色

    LoadStopPushButton();//初始化按钮及大小
    LoadStopSettingItems();
    LoadStopPicture();//设置各元素图片
    LoadStopPos();//设置各元素位置
    LoadStopAddItem();//添加各元素至背景
    StopButtonConnect();//初始化按钮的连接

}

void GameControl::Stop()
{
    //关闭计时器
    mMSTimer->stop();//谱面移动计时器
    mDelay->stop();//开始前缓冲计时器
    mDetectKeyTimer->stop();//检测按键计时器(包括边界判定)
    MSDelay->stop();//结算界面计时器
    MusicTimer->stop();

    //暂停BGM
    mMS->BGMPlayer->pause();

    //弹出暂停界面
    mGameView.setScene(&mStopScene);
    mGameView.show();
}

void GameControl::GameContinue()
{
    //切屏
    //mEndScene.removeItem(&mStopRect);
    mMainScene.addItem(&mStopRect);
    mMainScene.addItem(mStopCountdown);
    mGameView.setScene(&mMainScene);
    mGameView.show();

    //开启延迟定时器
    stopDelay->start(3000);
    connect(stopDelay,&QTimer::timeout,[this](){
        stopDelay->stop();
        //恢复主场景
        mMainScene.removeItem(&mStopRect);
        mMainScene.removeItem(mStopCountdown);
        LoadStopAddItem();

        //打开计时器
        mMSTimer->start(GameDefine::MSTime);//打开谱面计时器
        mDetectKeyTimer->start(GameDefine::Border);//打开判定检测器
        MSDelay->start(mMS->getMusicLenth() - mMS->getMusicTime() + GameDefine::EndDelay);//结算界面计时器
        MusicTimer->start(1);

        //继续播放BGM
        mMS->BGMPlayer->play();
    });
}

void GameControl::LoadStopPicture()

{   LoadStopAddEffect();//给背景图片添加效果

    mStopRect.setPixmap(QPixmap(":/img/EndBackGround.png"));
    mStopRect.setGraphicsEffect(mStopRectBGOpacityEffect);

    mStopBackground.setPixmap(QPixmap(mMS->getBackGround()));
    mStopBackground.setGraphicsEffect(mSBGBlurEffect);
    mStopBackground.setGraphicsEffect(mSBGOpacityEffect);

    //给按钮添加图片
    Continue->setIcon(QIcon(":/img/ContinueButton.png"));
    Continue->setIconSize(QSize(75,75));
    Quit->setIcon(QIcon(":/img/QuitButton.png"));
    Quit->setIconSize(QSize(75,75));
}

void GameControl::LoadStopSettingItems()
{
    //标签初始化
    mStopCountdown = new QGraphicsTextItem("准备继续");
    mStopCountdown->setDefaultTextColor(QColor(255,255,255));//颜色
    mStopCountdown->setFont(QFont("幼圆",60,80));//字体

    mStopText = new QGraphicsTextItem("游戏暂停");
    mStopText->setDefaultTextColor(QColor(0,0,0));//颜色
    mStopText->setFont(QFont("幼圆",60,80));//字体

    mContinueText = new QGraphicsTextItem("继续游戏");
    mContinueText->setDefaultTextColor(QColor(0,0,0));//颜色
    mContinueText->setFont(QFont("幼圆",40,80));//字体

    mQuitText = new QGraphicsTextItem("退出游戏");
    mQuitText->setDefaultTextColor(QColor(0,0,0));//颜色
    mQuitText->setFont(QFont("幼圆",40,80));//字体


}

void GameControl::LoadStopPushButton()
{
    Continue = new QPushButton;
    Quit = new QPushButton;

    //设置按钮大小
    Continue->resize(75,75);
    Quit->resize(75,75);
}

void GameControl::LoadStopPos()
{
    mStopBackground.setPos(0,0);
    mStopRect.setPos(0,100);
    Continue->move(200,365);
    Quit->move(500,365);
    mStopText->setPos(225,115);
    mContinueText->setPos(125,275);
    mQuitText->setPos(440,275);
    mStopCountdown->setPos(250,250);
}

void GameControl::LoadStopAddItem()
{
    mStopScene.addItem(&mStopBackground);
    //mStopScene.addItem(&mStopRect);
    mStopScene.addWidget(Continue);
    mStopScene.addWidget(Quit);
    mStopScene.addItem(mStopText);
    mStopScene.addItem(mContinueText);
    mStopScene.addItem(mQuitText);
}

void GameControl::LoadStopAddEffect()
{
    mSBGBlurEffect = new QGraphicsBlurEffect(this);//模糊效果
    mSBGBlurEffect->setBlurRadius(30);

    mSBGOpacityEffect = new QGraphicsOpacityEffect(this);//透明效果
    mSBGOpacityEffect->setOpacity(0.7);

    mStopRectBGOpacityEffect = new QGraphicsOpacityEffect(this);//透明效果
    mStopRectBGOpacityEffect->setOpacity(0.7);
}

void GameControl::StopButtonConnect()
{
    //暂停按钮跳转暂停界面
    connect(stop,&QToolButton::clicked,this,&GameControl::Stop);

    //继续按钮跳转回主界面
    connect(Continue,&QToolButton::clicked,this,&GameControl::GameContinue);
}
